<%@ page language="java" import="java.util.*,com.beans.*,com.dao.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>  
<html>
  <head>
    <base href="<%=basePath%>"> 
    <title>会员管理</title>
	<script type="text/javascript" src="js/jquery-1.8.0.js"></script> 
	<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>	
	


	<script type="text/javascript">
		$(function(){
			$("#ch_checkall").click(function(){
				if($("#ch_checkall").attr("checked")=="checked"){
					$("input[name=ck_id]").attr("checked","checked");
				}else{
					$("input[name=ck_id]").removeAttr("checked");
				}		
			});
			
			
			$("table tr").mouseover(function(){
				$(this).css("background","#D3EAEF");
				$(this).siblings().css("background","white");
			});
		});
	
	</script>

	<script>
		function subForm(pageIndex)
		{
		    //pageIndex 不传入,表示,是点击"转到"按钮的时候触发的
		    if(pageIndex){
		    	$("#pageIndex").val(pageIndex);
		    	document.form1.submit();
		    }
		    else{
		    	document.form1.submit();
		    }	
		}
		
		//删除一个
		function delOne(id,pageIndex){
			if(confirm("确定要删除吗")){
				window.location.href="MemberServlet.do?flag=del&id="+id+"&pageIndex="+pageIndex;
			}
		}
		
	</script>
	<link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
    <style>
    	.div_tools{
    		width:99.5%; 
			height:28px;
			background:#D3EAEF;
			margin:0px auto;
			margin-top:5px;
			margin-bottom:5px;
			font-size:12px;
			position:relative;	 
			
    	}
    	
    	.div_tools select{
    		height:22px;
    		font-size:12px;
			margin-top:3px;
    	}
    	
    	#btnsubmit{
    		width:40px;
    		height:20px;
    		font-size:12px;
    	}
    	
 
    </style>

  </head>
  
  <body>

				<div class ="div_title">
						<div class="div_titlename"> <img src="images/san_jiao.gif" ><span>会员列表</span></div>
						<div class="div_titleoper"><input type="checkbox"  /> 全选 <a href="#"> <img src="images/add.gif"/>添加 </a> <a href="javascript:delMuti()"><img src="images/del.gif"/>删除</a> <a href="#">  <img src="images/edit.gif"/>编辑 </a></div>
				 </div>
				 <form action="MemberServlet.do?flag=manage" method="post" name="form1">
				 <div class ="div_tools">
				 	 &nbsp; &nbsp; &nbsp;
				 	  会员帐号: <input type="text" name="memberNo" value="${param.memberNo }"></input>

				 	注册日期从: <input type="text" name="beginDate" onclick="WdatePicker()" value="${param.beginDate}" /> 到:
				 	
				 	<input type="text" name="endDate"  onclick="WdatePicker()" value="${param.endDate}" />
				 	
				 	<input id="btnsubmit" type="submit"  value="查询" />
				 </div>
				
				 <input type="hidden" name="flag" value="delAdmins" />
				 <table class="main_table" >
				       <tr>
				 				<th><input type="checkbox" id="ch_checkall" /></th>	
				 				<th>账号</th> 	
				 				<th>姓名</th>  
				 				<th>电话</th> 
				 				<th>邮箱</th> 
				 				<th>注册日期</th> 
				 				<th>会员等级</th>  
				 				<th>操作</th>
				 		</tr>
				 		<c:forEach var="m" items="${memberList}">
				 		<tr>
				 				<td>
				 					<input type="checkbox" name="ck_id" value="${m.id}" /> 
				 				</td>
				 				<td>${m.memberNo }</td>	
				 				<td>${m.memberName }</td>	
				 				<td>${m.phone }</td>	
				 				<td>${m.email }</td>	
				 				<td>${m.registerDate }</td>
				 				<td>${m.memberLevel }</td>
				 				<td>
					 				<a href="member/member_detail.jsp?id=${m.id}" >查看</a> |  		
					 			    <a href="javascript:delOne(${m.id},${pageInfo.pageIndex })">删除</a> 

				 				</td>
				 		</tr>
				   		 </c:forEach>
				 	
				</table>
				
				
				
				<div class="div_page" >
					  <div class="div_page_left">    共有 <label>${pageInfo.rowCount }</label> 条记录，当前第 <label>${pageInfo.pageIndex }</label> 页，共 <label>${pageInfo.pageCount }</label> 页	</div>
					
						
					  <div class="div_page_right" > 	 
						  	<c:choose>
						  		<c:when test="${pageInfo.hasPre }" >
					  			    <button onclick="subForm(1)" >首页</button>
					  	 			<button onclick="subForm(${pageInfo.pageIndex-1})">上一页</button>	
						  		</c:when>
						  		
						  		<c:otherwise>
						  			 首页
					  	 			 上一页
						  		</c:otherwise>	
						  	</c:choose>
						  	
						 	<c:choose>
						  		<c:when test="${pageInfo.hasNext}" >
					  			    <button onclick="subForm(${pageInfo.pageIndex+1})">下一页</button>
					  	 			<button onclick="subForm(${pageInfo.pageCount})">尾页</button>	
						  		</c:when>
						  		
						  		<c:otherwise>
						  			下一页 
					  	 		         尾页
						  		</c:otherwise>	
						  	</c:choose>
				
						  	 <button onclick="subForm()">转到</button>
						  	 <input type="text" name="pageIndex" id="pageIndex" value="${pageInfo.pageIndex }" /> 页
					  	
					   </div>
				</div>

			</form>
	  <script type="text/javascript">
	  	 var msg='${msg}';
	  	 if(msg!=''){
	  	 	alert(msg);
	  	 }
	  </script>
  </body>
</html>
